package com.yc.hwc.bean;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;

@Entity
@Table
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Article implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Column(columnDefinition = "timestamp default CURRENT_TIMESTAMP")
	private Timestamp inTime;
	@OneToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "in_user")
	private User inUser;

	@Column(length = 50)
	@NotEmpty(message = "标题不能为空！")
	@Length(min = 5, max = 50)
	private String title;
	@Column(length = 2000)
	@NotEmpty(message = "地址不能为空！")
	private String content;
	@OneToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "type")
	@NotNull(message = "类别不能为空！")
	private Dict type;
	private String tags;
	@OneToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "course_id")
	@NotNull(message = "课程不能为空！")
	private Course course;
	// 浏览次数
	private Integer readCnt;
	private String titleImg;

}
